package com.ats.web.managed;

import java.util.List;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

import com.ats.ereg.model.entities.TstStudents;
import com.ats.ereg.model.service.TstStudentsService;

@ManagedBean(name = "tstStudentsMB")
@ViewScoped
public class TstStudentsMB {
	private TstStudents firstEntity;
	private TstStudents secondEntity;
	private TstStudents thirdEntity;
	

	private List<TstStudents> entitiesList;
	private List<TstStudents> filteredEtitiesList;
	private List<TstStudents> selectedEtitiesList;
	private TstStudents selectedEntity = new TstStudents();

	@ManagedProperty(value = "#{TstStudentsService}")
	private TstStudentsService service;

	@PostConstruct
	private void init(){
		setEntitiesList( getService().getAllItems());
	}
	
	public TstStudents getSelectedEntity() {
		if (selectedEntity == null)
			selectedEntity = new TstStudents();
		return selectedEntity;
	}

	/**
	 * @param selectedEntity the selectedEntity to set
	 */
	public void setSelectedEntity(TstStudents selectedEntity) {
		this.selectedEntity = selectedEntity;
	}
	
	/**
	 * @return the entitiesList
	 */
	public List<TstStudents> getEntitiesList() {
	    if (entitiesList == null) {
	        entitiesList = getService().getAllItems();
	    }
		return entitiesList;
	}

	/**
	 * @param entitiesList the entitiesList to set
	 */
	public void setEntitiesList(List<TstStudents> entitiesList) {
		this.entitiesList = entitiesList;
	}

	/**
	 * @return the filteredEtitiesList
	 */
	public List<TstStudents> getFilteredEtitiesList() {
		return filteredEtitiesList;
	}

	/**
	 * @param filteredEtitiesList the filteredEtitiesList to set
	 */
	public void setFilteredEtitiesList(List<TstStudents> filteredEtitiesList) {
		this.filteredEtitiesList = filteredEtitiesList;
	}

	/**
	 * @return the selectedEtitiesList
	 */
	public List<TstStudents> getSelectedEtitiesList() {
		return selectedEtitiesList;
	}

	/**
	 * @param selectedEtitiesList the selectedEtitiesList to set
	 */
	public void setSelectedEtitiesList(List<TstStudents> selectedEtitiesList) {
		this.selectedEtitiesList = selectedEtitiesList;
	}

	/**
	 * @return the service
	 */
	public TstStudentsService getService() {
		return service;
	}

	/**
	 * @param service the service to set
	 */
	public void setService(TstStudentsService service) {
		this.service = service;
	}

	/**
	 * @return the firstEntity
	 */
	public TstStudents getFirstEntity() {
		if(firstEntity == null){
			firstEntity = getEntitiesList().get(0);
		}
		return firstEntity;
	}

	/**
	 * @param firstEntity the firstEntity to set
	 */
	public void setFirstEntity(TstStudents firstEntity) {
		this.firstEntity = firstEntity;
	}

	/**
	 * @return the secondEntity
	 */
	public TstStudents getSecondEntity() {
		if(secondEntity == null){
			secondEntity = getEntitiesList().get(1);
		}		
		return secondEntity;
	}

	/**
	 * @param secondEntity the secondEntity to set
	 */
	public void setSecondEntity(TstStudents secondEntity) {
		this.secondEntity = secondEntity;
	}

	/**
	 * @return the thirdEntity
	 */
	public TstStudents getThirdEntity() {
		if(thirdEntity == null){
			thirdEntity = getEntitiesList().get(2);
		}		
		return thirdEntity;
	}

	/**
	 * @param thirdEntity the thirdEntity to set
	 */
	public void setThirdEntity(TstStudents thirdEntity) {
		this.thirdEntity = thirdEntity;
	}


}
